{template 'common/header'}
<div class="panel we7-panel ng-scope" >
	<div class="panel-heading">首页弹窗设置</div>
	<div class="panel-body we7-padding">
			<div class="form-horizontal">
			<div class="form-group">
				<label class="col-sm-2 control-label">广告标题</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="title" name="title" value="{$ad['title']}">
				</div>
		 	</div>	
			<div class="form-group">
				<label class="col-sm-2 control-label">广告简语</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="info" name="info" value="{$ad['info']}">
				</div>
		 	</div>		 	 	
			<div class="form-group">
				<label class="col-sm-2 control-label">间隔时间</label>
				<div class="col-sm-8">
				    <div class="input-group">
				      <div class="input-group-addon">间隔</div>
				      <input type="number" class="form-control"  id="interval" placeholder="默认7200秒" value="{$ad['interval']}">
				      <div class="input-group-addon">秒</div>
				    </div>			
				</div>
		 	</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">广告图片</label>
				<div class="col-sm-8">
					  {php echo tpl_form_field_image('images',$ad['images']);}
					  <span class="help-block">&nbsp;&nbsp;建议格式为 600*400</span>
				</div>
		 	</div>	
	  	<div class="form-group">
	    	<label class="col-sm-2 control-label">链接选择</label>
	    	<div class="col-sm-8">
		    <select class="form-control"  id="url" name="url">
		    	<option value="/mii_ang/pages/card/card" {if $ad['url']=='/mii_ang/pages/card/card'}selected{else}{/if}>卡券领取中心</option>
		    	<option value="/mii_ang/pages/personal/index" {if $ad['url']=='/mii_ang/pages/personal/index'}selected{else}{/if}>个人中心</option>
		    	<option value="/mii_ang/pages/membercard/index" {if $ad['url']=='/mii_ang/pages/membercard/index'}selected{else}{/if}>会员卡</option>
		     </select>
		    </div>
		   </div>
		    <div class="form-group">
		        <label class="col-sm-2 control-label">是否开启</label>
		        <div class="col-sm-8">
		        <label class="radio-inline">
		          <input type="radio" name="firing" id="firing" value="0" {if $ad['firing']!='1'}checked="checked"{else}{/if}>关闭</label>
		          <label class="radio-inline">	
		          <input type="radio" name="firing" id="firing" value="1" {if $ad['firing']=='1'}checked="checked"{else}{/if}>开启
		        </label>
		        <span class="help-block">&nbsp;&nbsp;开启后用户每次进入首页会有广告提示</span>
		      </div>            
		    </div>		 		 		 		 		
			<br/>			 	
			<button type="button" id="save_info" class="btn btn-info" style="display: block; margin-left: auto;margin-right: auto;">提交保存</button>
		</div>
	</div>
</div>
<style type="text/css">.right-content{padding: 0;}</style>
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script>  
<script>
	$("#save_info").on(
        "click",function(){
		   		var title = $.trim($('#title').val());
		   		var info = $.trim($('#info').val());
		   		var interval = $.trim($('#interval').val());		   		
		   		var images = $.trim($('input[name="images"]').val());
		   		var url = $.trim($('#url option:selected').val());
		   		var firing = $.trim($("input[name='firing']:checked").val());  
		   		if(title==''){
		   			mqToast({type:1,context: '请填写广告标题'});
		   			return false;
		   		}
		   		if(info==''){
		   			mqToast({type:1,context: '请填写广告简语'});
		   			return false;
		   		} 
		   		if(images==''){
		   			mqToast({type:1,context: '请填写广告图片'});
		   			return false;
		   		}		   		  		
		   		if(url==''){
		   			mqToast({type:1,context: '请选择广告链接'});
		   			return false;
		   		}
		   		if(firing==''){
		   			mqToast({type:1,context: '请选择是否开启'});
		   			return false;
		   		}		   									   		
				$.ajax({
					url:"{php echo $this->createWebUrl('save_setadinfo');}&version_id="+"{$_GPC['version_id']}",
					data:{title:title,info:info,images:images,interval:interval,url:url,firing:firing},
					dataType:"json",
					type:"post",
					success:function(res){
						if(res.status==1){
							mqToast({type:1,context:res.msg});
							return false;
						}else{
							mqToast({type:2,context:res.msg});
							return false;
						}
					}
				});		   		
        });

</script>
{template 'common/footer'}
